package com.netstar.property;

import java.io.IOException;

import org.json.JSONException;

public abstract class LongProperty extends PrimitiveProperty {

	public abstract void set(Property obj, long val);

	public abstract long get(Property obj);

	public LongProperty(String propertyName) {
	}

	@Override
	public void copy(Property lhs, Property rhs) {
		set(lhs, get(rhs));
	}

	@Override
	public void parse(Property obj, Object value) throws JSONException,
			IOException {
		if (value == null) {
			set(obj, 0);
		} else {
			set(obj, Long.parseLong(value.toString()));
		}
	}

	public void set(Property obj, String val) {
		set(obj, Long.valueOf(val).longValue());
	}
}
